/*
 * StatusBarDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef STATUSBARDELEGATE_H
#define STATUSBARDELEGATE_H

#include "Cute4jSwing.h"

#include "ContainerDelegate.h"

// StatusBarDelegate Class. ----------------------------------------------------

/*!
 * \brief StatusBar Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT StatusBarDelegate : public ContainerDelegate
{
  Q_OBJECT
protected:
  StatusBarDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void showMessage(JNIEnv *env, jstring message, jint timeout);
  void clearMessage(JNIEnv *env);
  void insertChild(JNIEnv *env, jlong childDelegate, jint index);
  void insertPermanentChild(JNIEnv *env, jlong childDelegate, jint index);  // TODO: check this
  void removeChild(JNIEnv *env, jlong childDelegate);
  void setSizeGripEnabled(JNIEnv *env, jboolean enabled);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void statusMessgeChanged(jstring message);
public:
  inline QStatusBar *qStatusBar() const;
public:
  virtual void setParentDelegate(ContainerDelegate *parentDelegate);
protected slots:
  void messageChangedSlot(const QString &message);
private:
  static jmethodID sm_statusMessgeChangedMID;
};

// StatusBarDelegate :: Public Inline Member Function. -------------------------

/*!
 * \brief Returns QStatusBar adaptee.
 *
 * \return QStatusBar adaptee
 */
inline QStatusBar *StatusBarDelegate::qStatusBar() const
{
  return static_cast<QStatusBar *>(qObject());
}

// Macro Definitions. ----------------------------------------------------------

#define STATUS_BAR_CAST(delegate) \
    (reinterpret_cast<StatusBarDelegate *>(delegate))
#define STATUS_BAR_DELEGATE STATUS_BAR_CAST(delegate)

#endif // STATUSBARDELEGATE_H
